<template>
  <section>
    <!-- 面包屑 -->
     <breadcrumbs></breadcrumbs>
 <!-- 查询条件 -->
    <el-form
      ref="searchForm"
      :model="searchForm"
      label-width="100px"
      inline
      class="demo-form-inline"
      size="small"
      style="border-bottom: 1px solid #f6f6f6"
    >
    <el-form-item label="提现状态" prop="key">

       <el-select v-model="searchForm.state" placeholder="请选择提现状态">
            <el-option label="处理中" value="0"></el-option>
            <el-option label="审核成功" value="1"></el-option>
            <el-option label="审核拒绝" value="2"></el-option>
          </el-select>
         <!-- 
        <el-input
          v-model="searchForm.state"
          placeholder="请输入提现状态"
        ></el-input> -->
      </el-form-item>
       
        <el-form-item>
        <el-button
          type="primary"
          @click="
            searchForm.current = 1;
            search();
          "
          >查询</el-button
        >
        <el-button @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 查询条件 -->
    <div class="data-container scroll-table">
      <div>
        <div class="ind-title lh50 f16">提现审核列表</div>
      </div>
      <el-table :data="tixianlist"
                style="width: 100%">
      
        <el-table-column prop="orderNo"
                         label="提现订单号">
        </el-table-column>
        
        <el-table-column prop="price"
                         label="提现金额（元）">
            
             <template slot-scope="scope">
                 {{scope.row.price/100}}
             </template>
        </el-table-column>
        <el-table-column prop="state"
                         label="提现状态">
             <template slot-scope="scope">
                    <p v-if="scope.row.state == 0">
                       处理中
                    </p>
                    <p v-if="scope.row.state == 1">
                       审核成功
                    </p>
                    <p v-if="scope.row.state == 2">
                       审核拒绝
                    </p>
             </template>
        </el-table-column>
        
        <el-table-column prop="inAcctName"
                         label="提现户名">
        </el-table-column>
        <el-table-column prop="inAcctNo"
                         label="提现账号">
        </el-table-column>
        <el-table-column prop="addtime"
                         label="申请提现时间">
        </el-table-column>
        <el-table-column fixed="right"
                         label="操作"
                         width="150">
          <template slot-scope="scope">
            <div class="btns">
              <el-button :underline="false"
                         type="primary"
                         v-if="scope.row.state == 0"
                         @click="examine(scope.row)">审核</el-button>
              <el-button :underline="false"
                         type="success"
                         v-if="scope.row.state == 1"
                       >已完成</el-button>
              <el-button :underline="false"
                         type="danger"
                          v-if="scope.row.state == 2"
                         @click="showDetail(scope.row.downContent)">拒绝原因</el-button>
            </div>

          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pages">
     <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
    <el-dialog title="审核拒绝提现详情"
               :visible.sync="addORUpdateVisible"
               width="700px">
      <el-input v-model="jujueyuanyin"
                       type="textarea"
                            disabled
                            auto-complete="off"></el-input>
      <div slot="footer"
           class="dialog-footer">
        <el-button @click.native="addORUpdateVisible = false">取消</el-button>
        <el-button type="primary"
                   @click.native="addORUpdateVisible=false">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="提现审核审核"
               :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="确认审核">
          <el-radio v-model="form.radio"
                    label="1">通过</el-radio>
          <el-radio v-model="form.radio"
                    label="2">拒绝</el-radio>
        </el-form-item>
        <el-form-item label="审核拒绝原因"
                      v-if="isShow">
          <el-input v-model="form.info"
                    type="textarea"
                    auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer"
           class="dialog-footer">
        <el-button @click="dialogFormVisible=false">取 消</el-button>
        <el-button type="primary"
                   @click="confimExamine()">确 定</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>
import btns from '@/components/btns.vue';
import mapS from '@/components/map.vue'
// import { validateMobilePhone } from '@/../../utils/tool'
import breadcrumbs from "@/components/breadcrumbs.vue";
export default {
  components: {
    btns,
    mapS,
    breadcrumbs,
  },
  data () {
    return {
      searchForm:{},
      state:-1,
      jujueyuanyin:'',
        tixianlist:[],
      form: {},
      isShow: false,
      dialogFormVisible: false,
      addOreditgoodsForm: {},
      editList: [],
      addhasFileIdHard: false,
      addlise: [],
      hasFileIdCardZ: false,
      editlng: 0,
      editlat: 0,
      hasFileIdHard: false,
      editForm: {},
      editformVisible: false,
      hasFileAmbient: false,
      hasFileBusiness: false,
      hasFileIdCardF: false,
      hasFileIdCard: false,
      hasFile: false,
      importFileUrl: this.GLOBAL.imgBaseUrl,
      lat: 0,
      lng: 0,
      childrenData: {},
      //步骤条
      successActive: 1, // 控制步骤条及填写条目的显示
      errorActive: 1,
      isShowSuccess: false,
      isShowError: false,
      successInfo: '',
      errorInfo: '',
      currentPage: 1,
      pageSize: 10,
      total: 0,
      data: [],
      tableData: [],
      tableSelection: [],
      addORUpdateVisible: false,
      funTit: '',
      pForm: null,
      dialogVisibleBySellSuccess: false,
      dialogVisibleBySellError: false,
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false,
      license: [],
      examineForm: {},
    }
  },
  watch: {
    form: {
      handler (newVal) {
        if (newVal.radio == 2) {
          this.isShow = true;
        } else {
          this.isShow = false;
        }
        // this.$set(this.addOreditgoodsForm.lat, newVal.lat);
        // this.$set(this.addOreditgoodsForm.lng, newVal.lng);
      },
      deep: true,
    }
  },
  created () {
    // this.dictlist();
    this.getList(this.currentPage, this.pageSize)
  },
  methods: {
    handleReset() {
        this.searchForm = {
            state:''
        }
      
      this.search();
    },
    search(){
      if(this.searchForm.stat==0){

      }
      this.getList(this.currentPage, this.pageSize,this.searchForm.state)
    },

    confimExamine () {
      let _self = this;
      // console.log(this.form.info);
      if (_self.form.radio == undefined) {
        _self.$message.error('请选择确认审核状态')
      } else {
        if (_self.form.radio == 1) {
          _self.$api.tixian.xiaohuishoushezhi({
            extractMoneyLogId: _self.examineForm.extractMoneyLogId,
            content:'',
            state: 1
          }).then((d) => {
            if (d.code == 200) {
              _self.dialogFormVisible = false;
              _self.$message.success('审核成功');
              _self.getList(this.currentPage, this.pageSize);
              // _self.sendms(1);
            } else {
              _self.$message.error(d.msg);
            }
          })
        } else if (_self.form.radio == 2 && _self.form.info == undefined) {
          _self.$message.error('请输入审核拒绝原因');
        } else if (_self.form.radio == 2 && _self.form.info != undefined) {
          _self.$api.tixian.xiaohuishoushezhi({
            extractMoneyLogId: _self.examineForm.extractMoneyLogId,
            content: _self.form.info,
            state: 2
          }).then((d) => {
            if (d.code == 200) {
              _self.dialogFormVisible = false;
              _self.$message.success('拒绝审核成功');
              _self.getList(this.currentPage, this.pageSize);
              // _self.sendms(2);
            } else {
              _self.$message.error(d.msg);
            }
          })
        }
      }
    },
    sendms (index) {
      let _self = this;
      if (index == 1) {
        this.$api.afterSale.sendSms({
          content: 1,
          phoneNum: _self.examineForm.leadPhone
        }).then(res => {
          if (res.code == 200) {
            this.$message.success('商家提示信息发送成功');
          } else {
            this.$message.error(res.msg);
          }
        })
      } else if (index == 2) {
        this.dialogFormVisible = true;
        this.$message.success('审核成功');
        this.getList();
        this.dialogFormVisible = false;
        this.$api.afterSale.sendSms({
          content: 2,
          phoneNum: _self.examineForm.leadPhone
        }).then(res => {
          if (res.code == 200) {
            this.$message.success('商家提示信息发送成功');
          } else {
            this.$message.error(res.msg);
          }
        })
      }
    },
    confimUnExamine () { },
    showDetail (row) {
      
      this.jujueyuanyin = row;
      this.addORUpdateVisible = true;
    },
     handleSizeChange(val) {
    this.pageSize = val;
    this.getList(this.currentPage, val);
    // eslint-disable-next-line no-console
    // console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getList(val, this.pageSize);
      // eslint-disable-next-line no-console
      // console.log(`当前页: ${val}`);
    },
   getList () {
     // console.log('123123', curr, page);
      this.$api.tixian.xiaohuishouList({
          type:1,
        current:this.currentPage,
        size:this.pageSize,
        beginTime:'',
        endTime:'',
        inAcctNo:'',
        state:this.searchForm.state
      }).then(d => {
        if (d.code == 200) {
         this.tixianlist = d.data;
        }
        else{
            this.$message.error(d.msg);
        }
      })
    },
    //审核 状态 2待审核 3拒绝 4通过 0下架 1上架 
    examine (row) {
      this.examineForm = row;
      this.dialogFormVisible = true;
    },
    //
    unexamine () {
      if (this.tableSelection.length != 1) {
        this.$message.error('请选中一行数据');
        return
      }
      if (this.tableSelection[0].state != 4) {
        this.$message.error('当前不是可审核状态');
      } else {
        this.$confirm('是否拒绝审核通过此条店铺, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$api.store.changeStoreState({
            state: 4,
            storeId: this.tableSelection[0].storeId
          }).then((d) => {
            if (d.code == 200) {
              this.$message.success('拒绝审核成功');
              this.getList(1, this.pageSize);
            } else {
              this.$message.error(d.msg);
            }
          })
        }).catch(() => {
          this.$message.info('已取消拒绝审核');
        })
      }
    },

  }
}
</script>

<style>
.info {
  margin-top: 20px;
  text-align: center;
}
.mytransfer .el-checkbox {
  display: block;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
}
.form-pager {
  margin-top: 20px;
}
.el-button {
  margin: 1px;
}
.img-feng {
  width: 120px;
  height: 120px;
}
.btns {
  display: flex;
  justify-content: space-between;
}
</style>
